package com.googlecode.xapper;

import nu.xom.Element;

public class ReadyMades {

	private static final String XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";

	public static final Element heading(Integer level) {
		
		if(level > 6 ) { throw new IllegalArgumentException("Six is the maximum HTML heading level"); }
		if(level < 1 ) { throw new IllegalArgumentException("One is the minimum HTML heading level"); }
		
		return new Element(String.format("h%d", level), XHTML_NAMESPACE);
	}
	
	public static final Element paragraph(String text) {
		Element paragraph = paragraph();
		paragraph.appendChild(text);
		
		return paragraph;
	}

	public static final Element heading(Integer level, String headingText) {
		Element heading = heading(level);
		heading.appendChild(headingText);
		
		return heading;
	}

	public static Element paragraph() {
		Element paragraph = new Element("p", XHTML_NAMESPACE);
		return paragraph;
	}
	
	public static Element div() {
		Element div = new Element("div", XHTML_NAMESPACE);
		return div;
	}
	
	public static Element page() {
		HtmlElementWrapper html = HtmlElementWrapper.create("html")
			.withChild("head")
			.withSibling("body");
		return html.asElement();
	}
}
